home *** CD-ROM | disk | FTP | other *** search
-
- ///////////////////////////////////////////////////////////////////////////////
- // Copyright 1995 by Potomac Software, Inc. Use of this material is subject to
- // the terms and conditions of the software license agreement.
-
- #ifndef __HTMLPAVC_H__
- #define __HTMLPAVC_H__
-
- #ifndef WEBLIB_NO_MFC
- #include <afxwin.h>
- #endif
- #include "htmlpars.h"
- #include "dispatvc.h"
-
- ///////////////////////////////////////////////////////////////////////////////
- // HTML parser classes.
- //
- // The CWeblibHtmlAPI class is a simple C++ wrapper around the API.
-
- class CWeblibHtmlAPI
- {
- public:
- CWeblibHtmlAPI();
- CWeblibHtmlAPI(LPCSTR lpszFilename,WORD wOptions);
- CWeblibHtmlAPI(LPCSTR lpszBuf,DWORD cbBuf,WORD wOptions);
- virtual ~CWeblibHtmlAPI();
-
- BOOL IsGood() const;
-
- BOOL ParseFile(LPCSTR lpszFilename,WORD wOptions);
- BOOL ParseBuf(LPCSTR lpszBuf,DWORD cbBuf,WORD wOptions);
- BOOL EndParse();
-
- virtual BOOL EnumParseTree(HWND hwndNotify,UINT nMsg) const;
-
- HELEMENT GetChild(HELEMENT hElement) const;
- HELEMENT GetParent(HELEMENT hElement) const;
- HELEMENT GetSibling(HELEMENT hElement,WORD wRel) const;
-
- UINT GetElementType(HELEMENT hElement) const;
- LPCSTR GetElementText(HELEMENT hElement) const;
-
- DWORD GetTextAttr(HELEMENT hElement) const;
-
- LPCSTR GetTagName(HELEMENT hElement) const;
- UINT GetTagType(HELEMENT hElement) const;
-
- HTAGATTR GetTagAttr(HELEMENT hElement,HTAGATTR hTagAttr,WORD *pwType,LPSTR lpszAttr,
- UINT cbAttr,LPSTR lpszValue,UINT cbValue) const;
- LPCSTR ExtractTagAttr(HELEMENT hElement,LPSTR lpszAttr) const;
-
- HELEMENT FindText(HELEMENT hElement,LPCSTR lpszText) const;
- HELEMENT FindSpecial(HELEMENT hElement,LPCSTR lpszSpecial) const;
- HELEMENT FindComment(HELEMENT hElement,LPCSTR lpszCommentText) const;
-
- HELEMENT FindTagType(HELEMENT hElement,UINT nType) const;
- HELEMENT FindTagName(HELEMENT hElement,LPCSTR lpszTag) const;
- HELEMENT FindTagAttr(HELEMENT hElement,UINT nType,LPCSTR lpszAttr,
- LPCSTR lpszValue) const;
-
- virtual BOOL EnumFindText(HELEMENT hElement,LPCSTR lpszText,
- HWND hwndNotify,UINT nMsg) const;
- virtual BOOL EnumFindSpecial(HELEMENT hElement,LPCSTR lpszSpecial,
- HWND hwndNotify,UINT nMsg) const;
- virtual BOOL EnumFindComment(HELEMENT hElement,LPCSTR lpszCommentText,
- HWND hwndNotify,UINT nMsg) const;
-
- virtual BOOL EnumFindTagType(HELEMENT hElement,UINT nType,
- HWND hwndNotify,UINT nMsg) const;
- virtual BOOL EnumFindTagName(HELEMENT hElement,LPCSTR lpszTag,
- HWND hwndNotify,UINT nMsg) const;
- virtual BOOL EnumFindTagAttr(HELEMENT hElement,UINT nType,LPCSTR lpszAttr,
- LPCSTR lpszValueText,HWND hwndNotify,UINT nMsg) const;
-
- protected:
- HPARSE GetParseHandle() const
- { return m_hParse; }
-
- private:
- HPARSE m_hParse;
- };
-
- ///////////////////////////////////////////////////////////////////////////////
- // If just want to use the above CWeblibHtmlAPI base class w/o MFC, then define
- // WEBLIB_NO_MFC in your project (for non-MSVC C++ compilers and class libraries).
-
- #ifndef WEBLIB_NO_MFC
-
- ///////////////////////////////////////////////////////////////////////////////
- // The CWeblibHtml derived class handles enumeration notification automatically,
- // invoking the proper virtual event handler method when an event is received. To use,
- // derive your own class from CWeblibHtml and override the notification handlers.
-
- class CWeblibHtml : public CWeblibHtmlAPI, public CWeblibDispatch
- {
- public:
- CWeblibHtml();
- CWeblibHtml(LPCSTR lpszFilename,WORD wOptions);
- CWeblibHtml(LPCSTR lpszBuf,DWORD cbBuf,WORD wOptions);
- virtual ~CWeblibHtml();
-
- BOOL IsGood() const;
-
- ///////////////////////////////////////////////////////////////////////////
- // New public methods intended to supplant all base class methods that take
- // a notification window and message (notifications are sent to internal window).
-
- BOOL EnumParseTree(UINT nEnumID);
-
- BOOL EnumFindText(HELEMENT hElement,LPCSTR lpszText,UINT nEnumID);
- BOOL EnumFindSpecial(HELEMENT hElement,LPCSTR lpszSpecial,UINT nEnumID);
- BOOL EnumFindComment(HELEMENT hElement,LPCSTR lpszCommentText,UINT nEnumID);
-
- BOOL EnumFindTagType(HELEMENT hElement,UINT nType,UINT nEnumID);
- BOOL EnumFindTagName(HELEMENT hElement,LPCSTR lpszTag,UINT nEnumID);
- BOOL EnumFindTagAttr(HELEMENT hElement,UINT nType,LPCSTR lpszAttr,LPCSTR lpszValueText,
- UINT nEnumID);
-
- ///////////////////////////////////////////////////////////////////////////
- // Notification event handlers (override in your CWeblibHtml-derived class).
-
- virtual BOOL OnParseTree(WORD wType,HELEMENT hElement,UINT nEnumID);
- virtual BOOL OnFindText(WORD wType,HELEMENT hElement,UINT nEnumID);
- virtual BOOL OnFindSpecial(WORD wType,HELEMENT hElement,UINT nEnumID);
- virtual BOOL OnFindComment(WORD wType,HELEMENT hElement,UINT nEnumID);
- virtual BOOL OnFindTagType(WORD wType,HELEMENT hElement,UINT nEnumID);
- virtual BOOL OnFindTagName(WORD wType,HELEMENT hElement,UINT nEnumID);
- virtual BOOL OnFindTagAttr(WORD wType,HELEMENT hElement,UINT nEnumID);
-
- ///////////////////////////////////////////////////////////////////////////
- // Internal window passes notification messages to Dispatch() method.
-
- virtual LRESULT Dispatch(UINT nMsg,WPARAM wParam,LPARAM lParam);
-
- private:
-
- ///////////////////////////////////////////////////////////////////////////
- // Override public base class methods that take a notification window as
- // private (i.e., unavailable) since notifications are now sent to m_pWnd.
-
- virtual BOOL EnumParseTree(HWND hwndNotify,UINT nMsg) const;
-
- virtual BOOL EnumFindText(HELEMENT hElement,LPCSTR lpszText,
- HWND hwndNotify,UINT nMsg) const;
- virtual BOOL EnumFindSpecial(HELEMENT hElement,LPCSTR lpszSpecial,
- HWND hwndNotify,UINT nMsg) const;
- virtual BOOL EnumFindComment(HELEMENT hElement,LPCSTR lpszCommentText,
- HWND hwndNotify,UINT nMsg) const;
-
- virtual BOOL EnumFindTagType(HELEMENT hElement,UINT nType,
- HWND hwndNotify,UINT nMsg) const;
- virtual BOOL EnumFindTagName(HELEMENT hElement,LPCSTR lpszTag,
- HWND hwndNotify,UINT nMsg) const;
- virtual BOOL EnumFindTagAttr(HELEMENT hElement,UINT nType,LPCSTR lpszAttr,
- LPCSTR lpszValueText,HWND hwndNotify,UINT nMsg) const;
-
- BOOL PushEnumStack(UINT nEnumID);
- BOOL PopEnumStack();
-
- CWnd *m_pWnd;
- CUIntArray m_EnumStack;
- };
-
- #endif // WEBLIB_NO_MFC
-
- #include "htmlpavc.inl"
-
- #endif
-